package com.goldplusgold.tradedelay.app.trade.pojo;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.goldplusgold.tradedelay.app.market.widget.chartutil.DateUtil;

import java.util.Comparator;

/**
 * Created by admin on 2017/6/1.
 */

public class TriggeredRecord implements Comparator<TriggeredRecord> {
    /**
     * id : 47e7c7b6a2304ee08359f0eb54fc67ca
     * prodCode : AU
     * mBearbullType : BULL
     * sltpType : TP
     * sltpPrice : 276.81
     * floatPrice : 4.73
     * lots : 2
     * commissionPrice : null
     * state : 0
     * triggerTime : null
     * createTime : 2017/05/31 11:14:38
     * updateTime : null
     */

    private String id;
    private String prodCode;
    private String bearbullType;
    private String sltpType;
    private String sltpPrice;
    private String floatPrice;
    private String lots;
    private String commissionPrice;
    private String state;
    private String triggerTime;
    private String createTime;
    private String updateTime;
    private int viewType;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProdCode() {
        return prodCode;
    }

    public void setProdCode(String prodCode) {
        this.prodCode = prodCode;
    }

    public String getBearbullType() {
        return bearbullType;
    }

    public void setBearbullType(String bearbullType) {
        this.bearbullType = bearbullType;
    }

    public String getSltpType() {
        return sltpType;
    }

    public void setSltpType(String sltpType) {
        this.sltpType = sltpType;
    }

    public String getSltpPrice() {
        return sltpPrice;
    }

    public void setSltpPrice(String sltpPrice) {
        this.sltpPrice = sltpPrice;
    }

    public String getFloatPrice() {
        return floatPrice;
    }

    public void setFloatPrice(String floatPrice) {
        this.floatPrice = floatPrice;
    }

    public String getLots() {
        return lots;
    }

    public void setLots(String lots) {
        this.lots = lots;
    }

    public String getCommissionPrice() {
        return commissionPrice;
    }

    public void setCommissionPrice(String commissionPrice) {
        this.commissionPrice = commissionPrice;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getTriggerTime() {
        return triggerTime;
    }

    public void setTriggerTime(String triggerTime) {
        this.triggerTime = triggerTime;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Object getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public int getViewType() {
        return viewType;
    }

    public void setViewType(int viewType) {
        this.viewType = viewType;
    }

    @Override
    public int compare(TriggeredRecord o1, TriggeredRecord o2) {
        String createTime = o1.getCreateTime();
        long time1 = 0;
        if (!TextUtils.isEmpty(createTime)) {
            time1 = DateUtil.getTimeLong(createTime);
        }

        String createTime2 = o2.getCreateTime();
        long time2 = 0;
        if (!TextUtils.isEmpty(createTime2)) {
            time2 = DateUtil.getTimeLong(createTime2);
        }

        if (time1 > time2)
            return 1;
        return -1;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TriggeredRecord that = (TriggeredRecord) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        return prodCode != null ? prodCode.equals(that.prodCode) : that.prodCode == null;

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (prodCode != null ? prodCode.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "TriggeredRecord{" +
                "id='" + id + '\'' +
                ", prodCode='" + prodCode + '\'' +
                ", bearbullType='" + bearbullType + '\'' +
                ", sltpType='" + sltpType + '\'' +
                ", sltpPrice='" + sltpPrice + '\'' +
                ", floatPrice='" + floatPrice + '\'' +
                ", lots='" + lots + '\'' +
                ", commissionPrice=" + commissionPrice +
                ", state='" + state + '\'' +
                ", triggerTime=" + triggerTime +
                ", createTime='" + createTime + '\'' +
                ", updateTime=" + updateTime +
                '}';
    }

}
